package com.test.springmybatis;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;

// 定义一个函数式接口
@FunctionalInterface
interface Greeting {
    void sayHello(String name);
}

public class Main {
    public static void main(String[] args) {
        Supplier<String> supplier =new Supplier<String>() {
            @Override
            public String get() {
                return "ggg";
            }
        };
        Greeting greeting = new Greeting() {
            @Override
            public void sayHello(String name) {
                System.out.println("Hello " + name);
            }
        };
        System.out.println(supplier.get());
        Supplier<String> supplier2=()->{return "ggg222";};
        System.out.println(supplier2.get());
        List<String> names = new ArrayList<>();
        names.add("Alice");
        names.add("Bob");
        names.add("Charlie");

        // 使用 Consumer 处理列表中的每个元素
        Consumer<String> printName =new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s+"ddd");
            }
        };

       names.forEach(printName);
    }
}

